import axios from './request'

// import { attendancesType } from './attendances'

// 王冠华
export let getApproval=(page,pageSize)=>axios.get(`/user/process/instance/${page}/${pageSize}`)
export let getRwm=()=>axios.get('/sys/qrcodeKey')
export let Logon=(obj)=>axios.post('sys/login',obj)
export let getDet=(id)=>axios.get(`/user/process/instance/${id}`)
export let getDetSp=(id)=>axios.get(`/user/process/instance/tasks/detail/${id}`)
export let getSocial=(obj={})=>axios.post('/social_securitys/list',obj)
export let getCity=()=>axios.get('/sys/city')
export let getBm=()=>axios.get('/company/department')
export let getId=(id)=>axios.get(`/social_securitys/${id}`)
export let getDetail=(id)=>axios.get(`/social_securitys/payment_item/${id}`)
export let getBb=()=>axios.get(`social_securitys/historys/202001?opType=1`)
export let getAdd=()=>axios.put(`social_securitys/historys/202001/newReport`)
export let Gd=()=>axios.post(`social_securitys/historys/202001/archive`)
 export let Salary=(page='',pageSize='',departmentChecks='',approvalsTypeChecks='')=>axios.get(`salarys/list?page=${page}&pageSize=${pageSize}&approvalsTypeChecks=${approvalsTypeChecks}&departmentChecks=${departmentChecks}`)
// export let Salary=(obj={})=>axios.post(`/social_securitys/list?${JSON.stringify(obj)}`)

// 王冠华
// export let getApproval = (page, pageSize) => axios.get(`/user/process/instance/${page}/${pageSize}`)
// export let getRwm = () => axios.get('/sys/qrcodeKey')
// export let Logon = (obj) => axios.post('sys/login', obj)
// 栾云鹏
// 角色接口
export let roleList = (page, pagesize) => axios.get(`/sys/role?page=${page}&pagesize=${pagesize}`)
export let roledel = (id) => axios.delete(`/sys/role/${id}`)
export let roleadd = (data) => axios.post(`/sys/role`, data)
export let roleupd = (id, data) => axios.put(`sys/role/${id}`, data)
export let rolexp = (id) => axios.get(`/sys/role/${id}`)
export let roleper = (data) => axios.put('/sys/role/assignPrem', data)


// 权限接口
export let perList = () => axios.get('/sys/permission')
export let peradd = (data) => axios.post('/sys/permission', data)
export let perupdate = (id, data) => axios.put(`/sys/permission/${id}`, data)
export let perdel = (id) => axios.delete(`/sys/permission/${id}`)
// 考勤接口
export const getAtt = async (page, pagesize, deptID) => {
    let res = await axios.get(`/attendances?page=${page}&pagesize=${pagesize}&deptID=${deptID}`)
    // console.log(res,'res');
    return res
}
// 查询考勤设置
export const getKao = async (departmentId) => {
    let res = await axios.get("/cfg/atte/item?departmentId=" + departmentId)
    return res
}
// 保存考勤设置
export const setKao = async (obj) => {
    let res = await axios.put("/cfg/atte", obj)
    return res
}
// 查询请假设置
export const getJq = async (departmentId) => {
    let res = await axios.get("/cfg/leave/list?departmentId=" + departmentId)
    return res
}
// 保存请假设置
export const setJq = async (obj) => {
    let res = await axios.post("/cfg/leave", obj)
    return res
}
// 查询加班设置
export const getJb = async (departmentId) => {
    let res = await axios.get("/cfg/extDuty/item?departmentId=" + departmentId)
    return res
}
// 保存加班设置
export const setJb = async (obj) => {
    let res = await axios.put("/cfg/extDuty", obj)
    return res
}
// 查询扣款设置
export const getKk = async (departmentId) => {
    let res = await axios.get("/cfg/ded/list?departmentId=" + departmentId)
    return res
}
// 保存扣款设置
export const setKk = async (obj) => {
    let res = await axios.post("/cfg/deduction", obj)
    return res
}
// 查询用户的考勤状态
export const getSta = async (userId) => {
    let res = await axios.get("/attendances/adtStatu/list?userId=" + userId)
    return res
}
// 设置用户的考勤状态
export const setSta = async (id,obj) => {
    let res = await axios.put(`/attendances/${id}`,obj)
    return res
}
// 修改
export const putData = async (id, obj) => {
    let res = await axios.put(`/sys/user/${id}`, obj)
    // console.log(res)
    return res
}
//获取部门列表参数
export const getDepartment = () => axios.get("/company/department")
//地图参数
export const getDitu=async()=>{
    const res=await axios.get("company/list")
    return res
}


// 张岳淼
export let getAll = () => axios.get('/home/data')
export let getzu = () => axios.get('/company/department')
//组织添加
export let getadd = (data) => axios.post(`/company/department`, data)
//获取项目负责人数据
export let getfu = () => axios.get('/sys/user/simple')
//删除组织数据
export let organdel = (id) => axios.delete(`/company/department/${id}`)
//部门回显
export let organbian = (id) => axios.get(`/company/department/${id}`)
//部门修改
export let organxiu = (id, data) => axios.put(`/company/department/${id}`, data)
//获取员工数据


export default {
    // 获取数据
    getData(page, pagesize, keyword, departmentId) {
      return axios.get(
        `/sys/user?page=${page}&pagesize=${pagesize}&keyword=${keyword}&departmentId=${departmentId}`
      );
    },
    //   获取员工基本信息
    getdept(id) {
      return axios.get(`/sys/user/${id}`);
    },
    //   修改员工信息
    putdept(id, data) {
      return axios.put(`/sys/user/${id}`, {
        staffPhoto: data.staffPhoto,
        id: data.id,
        mobile: data.mobile,
        username: data.username,
        timeOfEntry: data.timeOfEntry,
        workNumber: data.workNumber,
        correctionTime: data.correctionTime,
        departmentId: data.departmentId,
        formOfEmployment: data.formOfEmployment,
      });
    },
    //   添加员工信息
    postdept(data) {
      return axios.post("/sys/user", {
        staffPhoto: data.staffPhoto,
        id: data.id,
        mobile: data.mobile,
        username: data.username,
        timeOfEntry: data.timeOfEntry,
        workNumber: data.workNumber,
        correctionTime: data.correctionTime,
        departmentId: data.departmentId,
        formOfEmployment: data.formOfEmployment,
      });
    },
    //   分配员工角色
    putDeptRoles(id, roles) {
      return axios.put(`/sys/user/assignRoles/${id}`, {
        id: id,
        roles: roles,
      });
    },
    // 获取组织数据
    getdepartment() {
      return axios.get("/company/department");
    },
    deldept(id) {
      return axios.delete(`/sys/user/${id}`);
    },
    // 获取角色接口
    getrole() {
      return axios.get("/sys/role/list/enabled");
    },
    setAssignRoles(obj){
      return axios.get(`/sys/user/assignRoles`,obj)
  }
  };
  
  /**
   * 获取可用的角色
   * **/
  
  export let getEnableRoleList = () => {
   return axios({
     url: "/sys/role/list/enabled",
   });
  };
  /**
   * 分配员工角色
   * ***/
  
  export let assignRole = (data) => {
    return axios({
      url: "/sys/user/assignRoles",
      method: "put",
      data,
    });
  };
  // 修改角色数据
  export const alertEnabled = async (id) => {
     const data = await axios.get(`/sys/user/${id}`)
     return data.data
  }
  
  // 发布通知数据
  export const getNotice = async (val) => {
     const data = await axios.post(`/sys/messageMuch`, val)
     return data.data
  }

